class Task43:
    def run(self, n):
        num_digits = 0
        temp = n
        while temp > 10:
            temp = temp // 10
            num_digits += 1

        if num_digits == 0:
            if n >= 1:
                return 1
            else:
                return 0

        base = self.power_10(num_digits)
        highest_digit = n // base
        remain = n % base

        if highest_digit == 1:
            count = remain + 1
        else:
            count = base
        count += highest_digit * num_digits * base // 10
        count += self.run(remain)
        return count

    def power_10(self, exponent):
        result = 1
        for i in range(exponent):
            result *= 10
        return result
